package com.slz3.business.module.messageManagement.mesOrder.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.messageManagement.mesOrder.domain.MesOrder;
import com.slz3.business.module.messageManagement.mesOrder.domain.MesOrderCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class MesOrderResController {

    @Resource
    private MesOrderResAtomic mesOrderResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, MesOrder mesOrder) {
        if (MesOrderResUnsafeValid.add(req, mesOrder)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.add_$MesOrderUpdateLock(req, mesOrder);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, MesOrderCondition mesOrderCondition) {
        if (MesOrderResUnsafeValid.delete(req, mesOrderCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.delete_$MesOrderUpdateLock(req, mesOrderCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, MesOrder mesOrder) {
        if (MesOrderResUnsafeValid.modify(req, mesOrder)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.modify_$MesOrderUpdateLock(req, mesOrder);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (MesOrderResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesOrderResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return mesOrderResAtomic.info_$MesOrderUpdateLock(req);
        if (MesOrderResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.info_$MesOrderUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (MesOrderResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesOrderResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, MesOrderCondition mesOrderCondition) {
        //
        if (MesOrderResUnsafeValid.auditSubmit(req, mesOrderCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.auditSubmit_$MesOrderUpdateLock(req, mesOrderCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, MesOrderCondition mesOrderCondition) {
        if (MesOrderResUnsafeValid.audit(req, mesOrderCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.audit_$MesOrderUpdateLock(req, mesOrderCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, MesOrderCondition mesOrderCondition) {
        if (MesOrderResUnsafeValid.auditReject(req, mesOrderCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.auditReject_$MesOrderUpdateLock(req, mesOrderCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, MesOrderCondition mesOrderCondition) {
        if (MesOrderResUnsafeValid.usingEnable(req, mesOrderCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.usingEnable_$MesOrderUpdateLock(req, mesOrderCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, MesOrderCondition mesOrderCondition) {
        if (MesOrderResUnsafeValid.usingDisable(req, mesOrderCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesOrderResAtomic.usingDisable_$MesOrderUpdateLock(req, mesOrderCondition);
        }
    }

}
